const connection = require("../db");

const getUserInfo = (req, res, next) => {
  const sql = "select * from tb_user where name = ?";
  // 获取token
  const { username } = req.auth;
  connection.query(sql, [username], (err, result) => {
    if (err) return res.status(500).json({ success: false, error: err });
    return res.status(200).json({
      success: true,
      data: result && result[0],
      message: "登录成功",
    });
  });
};

module.exports = { getUserInfo };
